/*
 * @lc app=leetcode.cn id=2535 lang=cpp
 *
 * [2535] 数组元素和与数字和的绝对差
 */

// @lc code=start
#include <bits/stdc++.h>
using namespace std;
class Solution
{
    int shuzihe(int n)
    {
        int ans = 0;
        while (n)
        {
            ans += n % 10;
            n /= 10;
        }
        return ans;
    }

public:
    int differenceOfSum(vector<int> &nums)
    {
        int sum1 = 0;
        int sum2 = 0;
        for (size_t i = 0; i < nums.size(); i++)
        {
            sum1 += nums[i];
            sum2 += shuzihe(nums[i]);
        }
        return abs(sum1 - sum2);
    }
};
// @lc code=end
